﻿@{
    Layout = null;
    Sysconfig config = ViewData["config"] as Sysconfig;
    List<Article> redGoods = ViewBag.redGoods as List<Article>;
    List<Article> newsList = ViewBag.newsList as List<Article>;
    List<Banner> bannerList = ViewBag.banner as List<Banner>;
    List<Shop> shopList = ViewBag.shop;
    List<Live> liveList = ViewBag.live as List<Live>;
}
<!DOCTYPE html>
<!--HTML5 doctype-->
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>首页</title>
    <link rel="stylesheet" type="text/css" href="/mobile/css/idangerous.swiper.css" />
    <link rel="stylesheet" type="text/css" href="/mobile/css/style.css" />
    <script type="text/javascript" charset="utf-8" src="/mobile/js/zepto.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="/mobile/js/weui.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="/mobile/js/common.js"></script>
    <script type="text/javascript" charset="utf-8" src="/mobile/js/idangerous.swiper-2.1.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            //初始化幻灯片
            var mySwiper = new Swiper('.swiper-container', {
                calculateHeight: true,
                resizeReInit: true,
                pagination: ".pagination",
                autoplay: 5000,
                paginationClickable: true
            });
            //选中Tab
            $(".weui-tabbar a").eq(0).addClass("weui-bar__item_on");
        });
    </script>
    <script src="https://res2.wx.qq.com/open/js/jweixin-1.4.0.js" type="text/javascript"></script>
    <script type="text/javascript">
                wx.config({
                    debug: false,
                    appId: '@ViewBag.appid',
                    timestamp: @ViewBag.ts,
                    nonceStr: '@ViewBag.noncestr',
                    signature: '@ViewBag.signature',
                    jsApiList: [
                        'getLocation'
                    ]
                });
                wx.ready(function () {
                    // 7.2 获取当前地理位置
                    //document.querySelector('#getLocation').onclick = function () {
                    //    getgps();
                    //};
                    $(document).ready(function (e) {
                        getgps();
                    });
                    function getgps() {
                        wx.getLocation({
                            success: function (res) {
                                //alert(JSON.stringify(res));
                                $.post("/Web/Index/EditGPS",
                                    {
                                        longitude: res.longitude,
                                        latitude: res.latitude
                                    },
                                    function (data) {
                                        console.log("定位成功");
                                        //document.querySelector('#getLocation').innerHTML = "定位成功";
                                    });
                            },
                            cancel: function (res) {
                                alert('用户拒绝授权获取地理位置');
                            }
                        });
                    }
                });
                wx.error(function (res) {
                    alert(res.errMsg);
                })
    </script>
</head>

<body ontouchstart>
    <div class="page">
        <!--页面头部-->
        @await Html.PartialAsync("~/Areas/Web/Views/Shared/_Header.cshtml")
        <!--/页面头部-->
        <!--页面内容-->
        <div class="page__bd">
            <!--首页幻灯片-->
            <div id="slider" class="swiper-container">
                <div class="swiper-wrapper">
                    @foreach (Banner item in bannerList)
                    {
                        <div class="swiper-slide"><img src="@item.img_url" /></div>
                    }
                </div>
                <div class="pagination"></div>
            </div>
            <!--/首页幻灯片-->
            <!--首页图标导航-->
            <div class="weui-grids nav-list">
                <a asp-area="Web" asp-controller="News" asp-action="Index" class="weui-grid">
                    <div class="weui-grid__icon">
                        <i class="iconfont icon-news"></i>
                    </div>
                    <p class="weui-grid__label">新闻资讯</p>
                </a>
                <a asp-area="Web" asp-controller="Goods" asp-action="Index" class="weui-grid">
                    <div class="weui-grid__icon">
                        <i class="iconfont icon-shopping"></i>
                    </div>
                    <p class="weui-grid__label">购物商城</p>
                </a>
                <a asp-area="Web" asp-controller="Shop" asp-action="Index" class="weui-grid">
                    <div class="weui-grid__icon">
                        <i class="iconfont icon-book"></i>
                    </div>
                    <p class="weui-grid__label">合作商家</p>
                </a>
                <a asp-area="Web" asp-controller="Video" asp-action="Index" class="weui-grid">
                    <div class="weui-grid__icon">
                        <i class="iconfont icon-video"></i>
                    </div>
                    <p class="weui-grid__label">直播导购</p>
                </a>
            </div>
            <!--/首页图标导航-->
            <!--新闻资讯-->
            <div class="weui-panel weui-panel_access">
                <div class="weui-panel__hd">新闻资讯</div>
                <div class="weui-panel__bd">
                    <div class="txt-list">
                        <ul>
                            @for (int i = 0; i < newsList.Count; i++)
                            {
                                if (i == 0)
                                {
                                    <li>
                                        <a asp-controller="News" asp-action="Show" asp-route-id="@newsList[i].id">
                                            <img src="@newsList[i].img_url" />
                                            <h2>@newsList[i].title</h2>
                                            <p class="intro">@newsList[i].zhaiyao</p>
                                        </a>
                                    </li>
                                }
                                else
                                {
                                    <li>
                                        <a asp-controller="News" asp-action="Show" asp-route-id="@newsList[i].id">
                                            <i class="date">@newsList[i].add_time.ToString("MM-dd")</i>
                                            <span class="text">@newsList[i].title</span>
                                        </a>
                                    </li>
                                }
                            }
                        </ul>
                    </div>
                </div>

                <div class="weui-panel__ft">
                    <a class="weui-cell weui-cell_access weui-cell_link" asp-area="Web" asp-controller="News" asp-action="Index">
                        <div class="weui-cell__bd">查看更多</div>
                        <span class="weui-cell__ft"></span>
                    </a>
                </div>
            </div>
            <!--新闻资讯-->
            <!--购物商城-->
            <div class="weui-panel weui-panel_access">
                <div class="weui-panel__hd">购物商城</div>
                <div class="weui-panel__bd">
                    <div class="txt-list">
                        <ul>
                            @foreach (Article dr in redGoods)
                            {
                                <li>
                                    <a asp-controller="Goods" asp-action="Show" asp-route-id="@dr.id">
                                        <img src="@dr.img_url" />
                                        <h2>@dr.title</h2>
                                        <div class="note">
                                            <p>@dr.zhaiyao</p>
                                            <p><i class="hot">@dr.click 人</i><i class="price">¥@dr.sell_price</i>元</p>
                                        </div>
                                    </a>
                                </li>
                            }
                        </ul>
                    </div>
                </div>

                <div class="weui-panel__ft">
                    <a class="weui-cell weui-cell_access weui-cell_link" asp-area="Web" asp-controller="Goods" asp-action="Index">
                        <div class="weui-cell__bd">查看更多</div>
                        <span class="weui-cell__ft"></span>
                    </a>
                </div>
            </div>
            <!--/购物商城-->
            <!--合作商家-->
            <div class="weui-panel weui-panel_access">
                <div class="weui-panel__hd">合作商家</div>
                <div class="weui-panel__bd">
                    <div class="photo-list">
                        <ul>
                            @foreach (Shop dr in shopList)
                            {
                                <li>
                                    <a asp-controller="Shop" asp-action="Show" asp-route-id="@dr.id" title="@dr.shopname">
                                        <img src="@dr.img_url" />
                                        <h2>@dr.shopname</h2>
                                    </a>
                                </li>
                            }
                        </ul>
                    </div>
                </div>
                <div class="weui-panel__ft">
                    <a class="weui-cell weui-cell_access weui-cell_link" asp-controller="Shop" asp-action="Index">
                        <div class="weui-cell__bd">查看更多</div>
                        <span class="weui-cell__ft"></span>
                    </a>
                </div>
            </div>
            <!--/合作商家-->
            <!--直播中心-->
            <div class="weui-panel weui-panel_access">
                <div class="weui-panel__hd">直播中心</div>
                <div class="weui-panel__bd">
                    <div class="photo-list">
                        <ul>
                            @foreach (Live dr in liveList)
                            {
                                <li>
                                    <a asp-controller="Video" asp-action="Show" asp-route-id="@dr.id" title="@dr.title">
                                        <img src="@dr.img_url" />
                                        <h2>@dr.title</h2>
                                    </a>
                                </li>
                            }
                        </ul>
                    </div>
                </div>
                <div class="weui-panel__ft">
                    <a class="weui-cell weui-cell_access weui-cell_link" asp-controller="Video" asp-action="Index">
                        <div class="weui-cell__bd">查看更多</div>
                        <span class="weui-cell__ft"></span>
                    </a>
                </div>
            </div>
            <!--/直播中心-->
            <!--版权信息-->
            @await Html.PartialAsync("~/Areas/Web/Views/Shared/_Copyright.cshtml")
            <!--/版权信息-->
            <!--底部导航-->
            @await Html.PartialAsync("~/Areas/Web/Views/Shared/_Footer.cshtml")
            <!--/底部导航-->
        </div>
        <!--/页面内容-->
    </div>
</body>
</html>